<template>
  <el-dialog
        title="导入流程数"
        v-model="dialogVisible"
        width="60%"
        @close="handleClose"
        custom-class="m-dialog-import-data"
        :append-to-body="true">
        <div style="height:50vh;overflow-y:auto;">
            <el-input v-model="graphJsonStr" :rows="15" type="textarea"></el-input>
        </div>
        <template #footer>
            <el-button @click="handleClose">取 消</el-button>
            <el-button type="primary" @click="handleSubmit">确 定</el-button>
        </template>
    </el-dialog>
</template>

<script  lang="ts">
import {ref, defineExpose, computed, unref, defineEmits} from 'vue'
export default {
    name: 'ImportData'
}
</script>

<script setup lang="ts">
const dialogVisible = ref(false)
const graphJsonStr = ref('')
// 定义外部事件
const emits = defineEmits(['on-submit'])

// 显示，由父组件调用
const show = () => {
    dialogVisible.value = true
}

// 处理确定按钮事件
const handleSubmit = () => {
    if (unref(graphJsonStr)) {
        emits('on-submit', unref(graphJsonStr))
        dialogVisible.value = false
    } else {
        ElMessage.error('导入数据不能为空')
    }
}

const handleClose = () => {
    dialogVisible.value = false
    graphJsonStr.value = ''
}


defineExpose({
    show
})

</script>

